package com.taropan.wallpaper.widget;

import android.widget.GridView;

public class CustomGridView extends GridView{
	 private boolean haveScrollbar = true;  
	public CustomGridView(android.content.Context context,
			android.util.AttributeSet attrs) {
		super(context, attrs);
	}
	   /**  
     * 设置是否有ScrollBar，当要在ScollView中显示时，应当设置为false。 默认为 true  
     *   
     * @param haveScrollbars  
     */  
    public void setHaveScrollbar(boolean haveScrollbar) {  
        this.haveScrollbar = haveScrollbar;  
    }  
  
    @Override  
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
        if (haveScrollbar == false) {  
            int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);  
            super.onMeasure(widthMeasureSpec, expandSpec);  
        } else {  
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);  
        }  
    }  
   
}
